layui.use(['element', 'layer'], function(){
    var element = layui.element;
    var layer = layui.layer;
    
    //监听折叠
    element.on('collapse(test)', function(data){
      layer.msg('展开状态：'+ data.show);
    });
  });
  layui.use('table', function(){
    var table = layui.table;
    var util = layui.util;
    table.render({
      elem: '#repair_table'
      ,url:head+'/student/search'
      ,method:"GET"
      ,where:{
        "sid":id
      }
      ,request: {
        pageName: 'pageNum' //页码的参数名称，默认：page
        ,limitName: 'pageSize' //每页数据量的参数名，默认：limit
      }
      ,title: '用户数据表'
      ,cols: [[ 
        {field:'studentAddr', title:'报修宿舍', width:150}
        ,{field:'state', title:'维修进度', width:150, templet:function(d){return getState(d.state)}}
        ,{field:'addTime', title:'结束时间',width:150, templet:function(d){return util.toDateString(d.ctime*1000,"yyyy-MM-dd HH:mm")}}
        ,{field:'msg', title:'维修信息', width:200} 
        ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:112}
      ]]
      ,page: true
    });
    
    
    //监听行工具事件
    table.on('tool(test)', function(obj){
      var data = obj.data;
      //console.log(obj)
      if(obj.event == 'history'){
        //弹出层
        layer.open({
          type: 2, 
          title:'历史详细',
          area: ['100%','100%'],
          offset:['0%','0%'],
          scrollbar: true,
          content: '../repair/repair_history_item.html?id='+data.id+'&type=0',//这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
          success: function(layero,index){
          
          }
         }) 
      }else if(obj.event == 'refuse'){
           //弹出层
        layer.open({
          type: 2, 
          title:'未读详细',
          area: ['100%','100%'],
          offset:['0%','0%'],
          scrollbar: true,
          content: '../repair/repair_refuse_item.html?id='+data.id,//这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
          success: function(layero,index){
          
          }
         }) 
      }else if(obj.event == 'running'){
           //弹出层
        layer.open({
          type: 2, 
          title:'处理中',
          area: ['100%','100%'],
          offset:['0%','0%'],
          scrollbar: true,
          content:'../repair/repair_history_item.html?id='+data.id+'&type='+3,//这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
          success: function(layero,index){
          
          }
         }) 
      }else if(obj.event == 'noread'){
        layer.open({
          type: 2, 
          title:'未读详细',
          area: ['100%','100%'],
          offset:['0%','0%'],
          scrollbar: true,
          content:  '../repair/repair_no_read_item.html?id='+data.id+'&type=0',
          success: function(layero,index){
          
          }
         }) 

      }
    });
  });
  